#include <iostream>
#include <fstream>
#include <string>
#include "hiout.pb.h"
using namespace std;

// This function fills in a Person message based on user input.
void promptForData(hi::TrackData* trackData) {
	cout << "Enter active: ";
	bool active;
	cin >> active;
	
	cout << "active was set to: " << active << endl ;
	
	trackData->set_active(active);
	cin.ignore(256, '\n');
	
	cout << "Enter x: ";
	int x;
	cin >> x;
	trackData->set_x(x);
	cin.ignore(256, '\n');
	
	cout << "Enter y: ";
	int y;
	cin >> y;
	trackData->set_y(y);
	cin.ignore(256, '\n');
	
}

// Main function:  Reads the entire address book from a file,
//   adds one person based on user input, then writes it back out to the same
//   file.
int main(int argc, char* argv[]) {
	// Verify that the version of the library that we linked against is
	// compatible with the version of the headers we compiled against.
	GOOGLE_PROTOBUF_VERIFY_VERSION;
	
	if (argc != 2) {
		cerr << "Usage:  " << argv[0] << " outfile" << endl;
		return -1;
	}
	
	hi::TrackData trackData;
	
	// Get data
	promptForData(&trackData);
	
	{
		// Write the new address book back to disk.
		fstream output(argv[1], ios::out | ios::trunc | ios::binary);
		if (!trackData.SerializeToOstream(&output)) {
			cerr << "Failed to write track data." << endl;
			return -1;
		}
	}
	
	// Optional:  Delete all global objects allocated by libprotobuf.
	google::protobuf::ShutdownProtobufLibrary();
	
	return 0;
}